package com.honey.mybatis.generator.dependent;

import com.honey.mybatis.generator.mappper.MapperConstant;

/**
 * 继承关系下的mapper id的映射关系
 * @author Administrator
 *
 */
public class ExtendMapperId implements DependentMapperId {

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getDeleteByDynamicMappingId()
	 */
	@Override
	public String getDeleteByDynamicMapperId() {
		
		return assembleMapperid(
			MapperConstant.DELETE_BY_DYNAMIC_MAPPER_ID
		);
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getVirtualDeleteByDynamicMapperId()
	 */
	@Override
	public String getVirtualDeleteByDynamicMapperId() {
		return assembleMapperid(
			MapperConstant.VIRTUAL_DELETE_BY_DYNAMIC_MAPPER_ID
		);
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getDeleteByPrimaryKeyMapperId()
	 */
	@Override
	public String getDeleteByPrimaryKeyMapperId() {
		return assembleMapperid(
			MapperConstant.DELETE_BY_PRIMARY_KEY_MAPPER_ID
		);
	}
	
	@Override
	public String getVirtualDeleteByPrimaryKeyMapperId() {
		return assembleMapperid(
			MapperConstant.VIRTUAL_DELETE_BY_PRIMARY_KEY_MAPPER_ID
		);
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getExistsMapperId()
	 */
	@Override
	public String getExistsMapperId() {
		return assembleMapperid(
			MapperConstant.EXISTS_MAPPER_ID
		);
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getInsertMapperId()
	 */
	@Override
	public String getInsertMapperId() {
		return assembleMapperid(
			MapperConstant.INSERT_MAPPER_ID
		);
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getInsertSelectiveMapperId()
	 */
	@Override
	public String getInsertSelectiveMapperId() {
		return assembleMapperid(
			MapperConstant.INSERT_SELECTIVE_MAPPER_ID
		);
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getSelectByDynamicMapperId()
	 */
	@Override
	public String getSelectByDynamicMapperId() {
		return assembleMapperid(
			MapperConstant.SELECT_BY_DYNAMIC_MAPPER_ID
		);
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getSelectByPrimaryKeyMapperId()
	 */
	@Override
	public String getSelectByPrimaryKeyMapperId() {
		return assembleMapperid(
			MapperConstant.SELECT_BY_PRIMARY_KEY_MAPPER_ID
		);
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getSelectCountMapperId()
	 */
	@Override
	public String getSelectCountMapperId() {
		return assembleMapperid(
			MapperConstant.SELECT_COUNT_MAPPER_ID
		);
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getUpdateByDynamicMapperId()
	 */
	@Override
	public String getUpdateByDynamicMapperId() {
		return assembleMapperid(
			MapperConstant.UPDATE_BY_DYNAMIC_MAPPER_ID
		);
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getUpdateByDynamicSelectiveMapperId()
	 */
	@Override
	public String getUpdateByDynamicSelectiveMapperId() {
		return assembleMapperid(
			MapperConstant.UPDATE_BY_DYNAMIC_SELECTIVE_MAPPER_ID
		);
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.dependent.DependentMapperId#getUpdateByPrimaryKeyMapperId()
	 */
	@Override
	public String getUpdateByPrimaryKeyMapperId() {
		return assembleMapperid(
			MapperConstant.UPDATE_BY_PRIMARY_KEY_MAPPER_ID
		);
	}

	@Override
	public String getUpdateByPrimaryKeySelectiveMapperId() {
		return assembleMapperid(
			MapperConstant.UPDATE_BY_PRIMARY_KEY_SELECTIVE_MAPPER_ID
		);
	}

	private String assembleMapperid(String id ){
		return new StringBuilder()
			.append("new StringBuilder( this.")
			.append(DependentConstant.NAMESPACE_METHOD_NAME)
			.append("() ).append(\"")
			.append(id)
			.append("\").toString()")
			.toString();
	}
	
	public static void main(String []args){
		ExtendMapperId em = new ExtendMapperId();
		System.out.println(em.getUpdateByPrimaryKeySelectiveMapperId());
		
	}

}
